//
//  TheOne_LocUpdateModel.m
//  lTTheOne
//
//  Created by SY on 2024/8/20.
//

#import "TheOne_LocUpdateModel.h"
#import "LocOneService.h"
#import "HeaderConfig.h"
#import "LocModel.h"
#import "MBProgressHUD+JDragon.h"
#import "MSUserManager.h"

@class TheCheckLocationCityModel;

@implementation TheOne_LocUpdateModel
- (void)locationUploadSuccess:(RequestSuccessBlock)success fail:(RequestFailBlock)fail{
    
    LocOneService *reuqest = [[LocOneService alloc] init];
    reuqest.requstType = Requstget;
    reuqest.city_name = [LocModel loc].cityName?:@"";

    [reuqest requst:^(id  _Nullable responseObject) {
        success(responseObject);
   } fail:^(NSError * _Nullable error, NSString * _Nullable errorStr) {
            if (kStringIsEmpty(errorStr)==NO) {
                [MBProgressHUD showSuccessMessage:errorStr];
            }
        fail(nil,errorStr);
    }];
    
}

+ (void)locationAlwaysUploadSuccess:(nonnull RequestSuccessBlock)success fail:(nonnull RequestFailBlock)fail {
 
    outliersOneService *request = [[outliersOneService alloc] init];
    request.full_name = [LocModel loc].Preciseaddress;
    request.position_latitude = [NSString stringWithFormat:@"%f",[LocModel loc].latitude];
    request.position_longitude = [NSString stringWithFormat:@"%f",[LocModel loc].longitude];
    request.device_id = [FCUUID uuidForDevice];
    
    request.city_name = [LocModel loc].cityName;
    id model=[MSUserManager sharedManager].checkLocModel;
    BOOL canUse = [[model valueForKey:@"can_use"] boolValue];
    request.warning_level = canUse?@"1":@"2";

    request.requstType = Requstget;

    if (!request.full_name||request.full_name==(NSString*)[NSNull null]||request.full_name.length==0) {
        return;
    }
    if (!request.city_name||request.city_name==(NSString*)[NSNull null]||request.city_name.length==0) {
        return;
    }

    [request requst:^(id  _Nullable responseObject) {
        
        success(responseObject);
   } fail:^(NSError * _Nullable error, NSString * _Nullable errorStr) {
            if (kStringIsEmpty(errorStr)==NO) {
                [MBProgressHUD showSuccessMessage:errorStr];
            }
        fail(nil,errorStr);
    }];
    
}

@end
